The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section.
Database replication is a mechanism for creation and maintenance of multiple copies (or replicas) of the same data in multiple databases. For example, a set of data and/or database objects from a source database is created in a destination database, and thereafter any changes made to the data and/or the database objects in the source database are propagated to and applied in the destination database. Based on how changes are tracked, several different types of replication can be used to replicate changes from a source database to a destination database.
Row-level replication is used to replicate changes at the data row level. In row-level replication, the changes are tracked as individual modifications to data rows in the source database and are applied as individual modifications to corresponding data rows in the destination database. For example, if 1000 data rows of a given table are updated at the source database, then 1000 separate updates are propagated and applied to 1000 data rows in the corresponding table in the destination database.
Statement-level replication is used to replicate changes at the database statement level. In statement-level replication, at the source database the changes are tracked as entire database statements, which statements are then replicated and executed at the destination database. For example, if a database statement updated 1000 data rows of a given table at the source database, then the database statement itself is replicated and executed at the destination database in order to update the corresponding table at the destination database.
Procedure-level replication is used to replicate changes at the stored procedure level. Procedure-level replication tracks calls to stored procedures at the source database, replicates to the destination database the procedure calls with their parameters, and causes execution of the corresponding stored procedures at the destination database based on the replicated procedure calls and the parameters thereof. Procedure-level replication is useful for replicating a procedure call, rather than the changes made to individual data rows by the called stored procedure, in operational scenarios where row-level replication may not produce equivalent results in the destination database because of various reasons such as different row identifiers, different version or implementation of the stored procedure, etc.
Typically, the replication latency in propagating and applying changes to a destination database is reduced when a combination of row-level replication, statement-level replication, and procedure-level replication is used to replicate the changes. One reason for this is that each type of replication improves replication performance in a different way, and so using a combination of the different types of replication for different types of changes yields a better overall performance than using only a single type of replication for all of the different types of changes. Further, in typical operational scenarios, a source database is configured to accept multiple sessions that can include a large number of connections over which database applications and clients can concurrently execute multiple transactions that make different types of changes to the data and data objects in the database.
However, when changes made by multiple transactions in a source database are replicated, significant replication latency can result because the typical replication mechanisms do not allow parallel application to a destination database of changes that have been replicated by using a combination of row-level replication, statement-level replication, and procedure-level replication. For example, suppose that two transactions need to be replicated from the source database to the destination database and each of the two transactions makes row-level, statement-level, and procedure-level changes to the source database. In this scenario, the typical replication mechanisms can only apply these changes to the destination database as a single thread or process even though at the source database the two transactions are executed concurrently and therefore their changes are applied to the source database in parallel.